#ifndef __IMAGE_H__
#define __IMAGE_H__

#include "../Common.h"
#include <map>
#include <string>

namespace RayFrame
{
  enum PixelFormat {
    PIXEL_UNKNOWN,

    // Gray scale image, all bits in lumiance
    PIXEL_L8,

    // 16 bits rgb image
    PIXEL_R5G6B5,
    PIXEL_A1R5G5B5,

    // 24 bits
    PIXEL_R8G8B8,
    PIXEL_B8G8R8,

    // 32 bits
    PIXEL_R8G8B8A8,
    PIXEL_B8G8R8A8,

    // n x 16 bits
    PIXEL_RGB16,
    PIXEL_RGBA16,

    // float
    PIXEL_F32,
    PIXEL_F64,
    PIXEL_RGBF32,
    PIXEL_RGBAF32,
  };

  /// This class keeps meta information and the pointer of actual image data
  class Image
  {
  public:
    unsigned m_width, m_height;
    int m_mipMaps;
    int m_bpp;
    PixelFormat m_format;
    STRING m_name, m_filename;
    bool m_isOK;
    unsigned m_size;
    unsigned char* m_data;
  public:
    Image()
    {
      m_isOK = false;
    };

    Image(const Image &img)
    {
      m_width = img.m_width;
      m_height = img.m_height;
      m_bpp = img.m_bpp;
      m_mipMaps = img.m_mipMaps;

      m_name = img.m_name;
      m_filename = img.m_filename;

      m_isOK = img.m_isOK;
      m_data = img.m_data;
    };

    ~Image()
    {
      SAFE_DELETE_ARRAY(m_data);
    };

    bool       IsOK(){ return m_isOK; };
    unsigned   GetWidth(){ return m_width; };
    unsigned   GetHeight(){ return m_height; };
    int        GetBpp(){ return m_bpp; };
    STRING     GetName(){ return m_name; };
    STRING     GetFilename(){ return m_filename; };
    PixelFormat  GetPixelFormat(){ return m_format; };
    unsigned   GetSize(){ return m_size; };
  };
}

#endif
